import Vue from 'vue'
import VueRouter from 'vue-router'
 

Vue.use(VueRouter)

  const routes = [
  {
    path: '/login',
    component: () => import('../views/admin/Login.vue')
  },
  {
    path: '/',
    redirect:'/sub-m1',
    component: () => import('../views/admin/Index.vue'),
    children:[
      {path: '/sub-m1',component: () => import('../views/model1/index.vue')},
      {path: '/sub-m2',component: () => import('../views/model2/index.vue')},
  ]
  },
]
// 处理重复点击同一个路由报错的问题
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (location) {
  return originalPush.call(this, location).catch((err) => err)
}
const router = new VueRouter({
  mode: 'history', 
  base: window.__POWERED_BY_QIANKUN__ ? '/app-vue/' : '/',
  routes
})


// 在Router实例上进行守卫
router.beforeEach((to, from, next) => {
  next()
})

export default router
